package cn.zcscloud.mall.service.impl;

import cn.zcscloud.mall.mbg.mapper.PmsBrandMapper;
import cn.zcscloud.mall.mbg.model.PmsBrand;
import cn.zcscloud.mall.mbg.model.SmsHomeBrand;
import cn.zcscloud.mall.service.PmsBrandService;
import cn.zcscloud.mall.service.SmsHomeBrandService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PmsBrandServiceImpl extends ServiceImpl<PmsBrandMapper, PmsBrand> implements PmsBrandService {

    @Autowired
    private SmsHomeBrandService smsHomeBrandService;

    /**
     * 批量删除品牌
     *
     * @param ids
     * @return
     */
    @Override
    public void deleteByIds(List<Integer> ids) {
        //删除两张表
        LambdaQueryWrapper<SmsHomeBrand> lqw = new LambdaQueryWrapper<>();
        lqw.in(SmsHomeBrand::getBrandId, ids);
        smsHomeBrandService.remove(lqw);
        this.removeByIds(ids);
    }

    /**
     * 删除品牌
     *
     * @param id
     * @return
     */
    @Override
    public void deleteById(Integer id) {
        //删除两张表
        LambdaQueryWrapper<SmsHomeBrand> lqw = new LambdaQueryWrapper<>();
        lqw.eq(SmsHomeBrand::getBrandId, id);
        this.removeById(id);
    }
}
